package com.yuw.collectionTools.comparedemo;

public class Student implements Comparable<Student> {
	// 属性
	private String stuName;
	private String stuNo;
	private int stuScore;
	// 行为

	/**
	 * 打印学生自己的信息
	 */
	public void printMe() {
		System.out.println("姓名：" + this.getStuName() + ",学号：" + this.getStuNo() + ",成绩：" + this.getStuScore());
	}

	public Student() {
		super();
	}

	public Student(String stuName, String stuNo, int stuScore) {
		super();
		this.stuName = stuName;
		this.stuNo = stuNo;
		this.stuScore = stuScore;
	}

	public String getStuName() {
		return stuName;
	}

	public void setStuName(String stuName) {
		this.stuName = stuName;
	}

	public String getStuNo() {
		return stuNo;
	}

	public void setStuNo(String stuNo) {
		this.stuNo = stuNo;
	}

	public int getStuScore() {
		return stuScore;
	}

	public void setStuScore(int stuScore) {
		this.stuScore = stuScore;
	}

	@Override
	public int compareTo(Student stu) {
		// 分别返回 -1、0 或 1 中的一个值，分别表示小于、等于或大于三种情况
		// 默认返回值
		int re_i = -1;
		if (stu != null) {
			if (this.getStuScore() > stu.getStuScore()) { // 大于情况
				re_i = 1;
			} else if (this.getStuScore() < stu.getStuScore()) {
				// 小于情况
				re_i = -1;
			} else {
				// 等于情况
				re_i = 0;
			}
		}
		return re_i * -1;
	}

}
